import { useNavigate } from "react-router-dom";

const Article = () => {
  // 调用useNavigate钩子函数获取导航方法
  const navigate = useNavigate();
  return (
    <>
      <div>Article组件</div>
      {/* 编程式路由导航 */}
      <button onClick={() => navigate("/login")}>返回登录页</button>
      <button onClick={() => navigate("/login?id=123&name=张三")}>
        返回登录页并传递searchParams参数
      </button>
      <button onClick={() => navigate("/login/001/张三")}>
        返回登录页并传递params参数
      </button>
    </>
  );
};

export default Article;
